package edu.object_oriented.API;

import java.util.Calendar;
import java.util.Date;

public class CalenderPra {

    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();
        System.out.println("calendar = " + calendar);
        //获取日历中的时间
        Date date = calendar.getTime();
        System.out.println(date);
        //设定日历
//        calendar.set(1,2021);
        calendar.set(2020,4,21,8,25,56);
        Date time = calendar.getTime();
        System.out.println("time = " + time);
        //指定字段进行日期的获取
        int i = calendar.get(Calendar.YEAR);
        System.out.println("i = " + i);

    }

}


/**
 * Date:获取本地时间    也可以设置时间
 * Calendar ：日历   表示时间
 * java8 :
 *  LocalDate / LocalTime / LocalDateTime
 *
 *
 */
